<%@ page import="com.zzuli.dcxt.entiy.Dishes" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 14408
  Date: 2022/1/11
  Time: 23:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>菜品管理</title>
</head>
<script type="text/javascript" src="../js/jquery.js"></script>
<body>
<div align="center">
    <table border="0" width="800" id="table1" bgcolor="#CCFFCC">
        <tr>
            <td colspan="4" align="center">
                <input type="text" id="keyword" name="keyword" size="40"> <input type="button" id="search" value="搜索">
            </td>
        </tr>
        <tr>
            <td align="center">菜品名称</td>
            <td align="center">原料</td>
            <td align="center">单价</td>
            <td align="center">说明</td>
            <td align="center">　</td>
            <td align="center"></td>
        </tr>
        <%
            List<Dishes> list=(List<Dishes>)session.getAttribute("dishes");
        %>
        <c:if test="${sessionScope.dishes!=null}">
            <c:forEach items="${sessionScope.dishes}" var="dishe">
                <tr>
                    <td bgcolor="#FFE3BB" align="center" height="20">${dishe.name}</td>
                    <td bgcolor="#FFE3BB" align="center" height="20">${dishe.material}</td>
                    <td bgcolor="#FFE3BB" align="center" height="20">${dishe.price}元</td>
                    <td bgcolor="#FFE3BB" align="center" height="20">${dishe.instructions}</td>
                    <td bgcolor="#FFE3BB" align="center" height="20"><a href="http://localhost:8080/dishes/selectOne.do?id=${dishe.id}">修改</a></td>
                    <td bgcolor="#FFE3BB" align="center" height="20"><a href="http://localhost:8080/dishes/delete.do?id=${dishe.id}">删除</a></td>
                </tr>
            </c:forEach>
        </c:if>

        <tr>
            <td bgcolor="#FFE3BB" align="center" colspan="6" height="25"><a href="http://localhost:8080/dishes/get.do">添加新菜品</a></td>
        </tr>
    </table>
</div>
<script>
    $(function(){

        $('#search').click(function () {
            $.ajax({
                type: 'post',
                url: 'http://localhost:8080/dishes/searchDishes.do',
                data: {
                    keyword: $("#keyword").val()
                },
                success: function (data) {
                    console.log("data====" + data);
                    $("#keyword").val(data)
                }
            });
        });
        //执行代码
        $.ajax({
            type:"GET",
            url:"http://localhost:8080/dishes/select.do",
            success: function (result) {
                console.log("result")
            }
        })
    })





</script>
</body>
</html>
